
<%@ include file="/commons/global.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>报销实例表</title>
</head>
<body class="easyui-layout" data-options="fit:true"
	style="font-family: '微软雅黑'">
	<div
		data-options="region:'center',split:true,border:false,title:'参合人员列表'">
		<div id="familyInfoTb" style="height: auto">
        <form id="searchCardForm">
            <table>
                <tr>
                    <th>身份证:</th>
                    <td><input name="cardNo" placeholder="请输入身份证"/></td>
                    <td>
                    
                        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'glyphicon-search',plain:true" onclick="searchCardFun();">查询</a>
                        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'glyphicon-remove-circle',plain:true" onclick="cleanCardFun();">清空</a>
                    </td>
                </tr>
            </table>
        </form>
		</div>
		<table id="familyInfoDg"></table>
	</div>
	<div
		data-options="region:'south',border:true,collapsible:false,title:'慢性病证列表'"
		style="height: 400px">
		<div id="tb" style="padding: 5px; height: auto">
			<div>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-remove" plain="true" data-options="disabled:false"
					onclick="del()">删除</a> <span
					class="toolbar-item dialog-tool-separator"></span> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-edit" plain="true" onclick="upd()">修改</a> <span
					class="toolbar-item dialog-tool-separator"></span>
			</div>
		</div>
		<table id="dg"></table>
	</div>
	<div id="dlg"></div>
	<script type="text/javascript">
		var dg;
		var familyInfoDg;
		var d;
		$(function() {
			dg = $('#dg').datagrid(
					{

						//		url : '${ctx}/exp/expInst/json',
						url : '${path}/expInst/dataGrid',
						striped : true,
						rownumbers : true,
						pagination : true,
						singleSelect : true,
						idField : 'expInstNo',
						sortName : 'expInstNo',
						sortOrder : 'asc',
						pageSize : 20,
						pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400,
								500 ],
						columns : [ [ {
							field : 'expInstNo',
							title : '报销实例编码',
							width : 100
						}, {
							field : 'illNo',
							title : '慢病证号',
							width : 100
						}, {
							field : 'cardNo',
							title : '身份证号',
							width : 100
						}, {
							field : 'allCost',
							title : '总花费',
							width : 100
						}, {
							field : 'bxPay',
							title : '报销金额',
							width : 100
						}, {
							field : 'treatTime',
							title : '就诊时间',
							width : 100

						}, {
							field : 'recodTime',
							title : '报销时间',
							width : 100
						}, {
							field : 'treateinNo',
							title : '发票编码',
							width : 100
						}, {
							field : 'treatAgenName',
							title : '就诊机构',
							width : 100
						} ,
						
						{
							field : 'action',
							title : '操作',
							width : 200,
							formatter : function(value, row, index) {
								var str = '';
								<shiro:hasPermission name="/expInst/edit">
								str += $
										.formatString(
												'<a href="javascript:void(0)" class="expInst-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="expInstEditFun(\'{0}\');" >编辑</a>',
												row.expInstNo);
								</shiro:hasPermission>
								<shiro:hasPermission name="/expInst/delete">
								str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
								str += $
										.formatString(
												'<a href="javascript:void(0)" class="expInst-easyui-linkbutton-del" data-options="plain:true,iconCls:\'fi-x icon-red\'" onclick="expInstDeleteFun(\'{0}\');" >删除</a>',
												row.expInstNo);
								</shiro:hasPermission>
								return str;
							}
						}] ],
						headerContextMenu : [
								{
									text : "冻结该列",
									disabled : function(e, field) {
										return dg.datagrid("getColumnFields",
												true).contains(field);
									},
									handler : function(e, field) {
										dg.datagrid("freezeColumn", field);
									}
								},
								{
									text : "取消冻结该列",
									disabled : function(e, field) {
										return dg.datagrid("getColumnFields",
												false).contains(field);
									},
									handler : function(e, field) {
										dg.datagrid("unfreezeColumn", field);
									}
								} ],
						enableHeaderClickMenu : true,
						enableHeaderContextMenu : true,
						enableRowContextMenu : false,
						toolbar : '#tb'
					});
		});

		$(function() {
			familyInfoDg = $('#familyInfoDg').datagrid(
					{

						url : '${path}/familyInfo/dataGridAll',
						striped : true,
						rownumbers : true,
						pagination : true,
						singleSelect : true,
						idField : 'familyInfoNo',
						sortName : 'familyInfoNo',
						sortOrder : 'asc',
						pageSize : 20,
						pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400,
								500 ],
						queryParams : {
							filter_EQS_partState : '已参合',
							filter_GTS_illCardNo : '0'
						},
						columns : [ [ {
							field : 'familyInfoNo',
							title : '成员编号',
							width : 150,
			                sortable : true
						}, {
							field : 'cardNo',
							title : '身份证号',
							width : 150,
			                sortable : true
						}, {
							field : 'name',
							title : '姓名',
							width : 100,
			                sortable : true
						}, {
							field : 'gender',
							title : '性別',
							width : 100,
			                sortable : true
						}, {
							field : 'age',
							title : '年齡',
							width : 100,
			                sortable : true
						}, {
							field : 'partState',
							title : '参合状态',
							width : 100,
			                sortable : true
						}, {
							field : 'illCardNo',
							title : '慢性病证号',
							width : 180,
			                sortable : true
						}, {
							field : 'opt',
							title : '操作',
							width : 150,
							formatter : partOper
						} ] ],
						headerContextMenu : [
								{
									text : "冻结该列",
									disabled : function(e, field) {
										return familyInfoDg.datagrid(
												"getColumnFields", true)
												.contains(field);
									},
									handler : function(e, field) {
										familyInfoDg.datagrid("freezeColumn",
												field);
									}
								},
								{
									text : "取消冻结该列",
									disabled : function(e, field) {
										return familyInfoDg.datagrid(
												"getColumnFields", false)
												.contains(field);
									},
									handler : function(e, field) {
										familyInfoDg.datagrid("unfreezeColumn",
												field);
									}
								} ],
						enableHeaderClickMenu : true,
						enableHeaderContextMenu : true,
						enableRowContextMenu : false,
						toolbar : '#familyInfoTb',
						onClickRow : function(rowIndex, rowData) {
							var cardNo = rowData.cardNo;
							partInstDg = $('#partInstDg');
							partInstDg.datagrid({
								url : '${ctx}/exp/illCard/json'
							});
							partInstDg.datagrid('reload', {
								filter_EQS_cardNo : cardNo
							})
						},
						onLoadSuccess : function(data) {
							var rows = data.rows;
							if (rows == null || rows == undefined
									|| rows.length == 0) {
								$.messager.alert('提示', '改身份证号未参合!');
							}
						}
					});
		});

		//弹窗增加
		function add() {
			d = $("#dlg").dialog({
				title : '确认报销',
				width : 380,
				height : 380,
				href : '${path}/expInst/add',
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '确认',
					handler : function() {
						$("#mainform").submit();
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}

		
		//弹窗修改
		function upd() {
			var row = dg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			d = $("#dlg").dialog({
				title : '修改报销实例表',
				width : 380,
				height : 340,
				//	href : '${ctx}/exp/expInst/update/' + row.expInstNo,
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '修改',
					handler : function() {
						$('#mainform').submit();
					}
				}, {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}
		/**
		 * 删除
		 */
		function expInstDeleteFun(expInstNo) {
			if (expInstNo == undefined) {//点击右键菜单才会触发这个
				var rows = expInstDataGrid.datagrid('getSelections');
				expInstNo = rows[0].expInstNo;
			} 
			parent.$.messager.confirm('询问', '您是否要删除当前角色？', function(b) {
				if (b) {
					progressLoad();
					$.post('${path}/expInst/delete', {
						expInstNo : expInstNo
					}, function(result) {
						if (result.success) {
						//	parent.$.messager.alert('提示', result.msg, 'info');
						//	expInstDataGrid.datagrid('reload');
						}
						progressClose();
					}, 'JSON');
				}
			});
		}

		//查看
		function look() {
			var row = dg.datagrid('getSelected');
			if (rowIsNull(row))
				return;
			d = $("#dlg").dialog({
				title : '查看报销实例表',
				width : 380,
				height : 340,
				//		href : '${ctx}/exp/expInst/' + row.expInstNo,
				maximizable : true,
				modal : true,
				buttons : [ {
					text : '取消',
					handler : function() {
						d.panel('close');
					}
				} ]
			});
		}

		//慢性病证办理
		function partOper(val, row, index) {
			if (row.illCardNo > '0' && row.partState == '已参合') {
				return '<a href="#" onclick="expAdd(\'' + row.cardNo
						+ '\')">慢性病报销</a>';
			}
		}

		//慢性病报销界面
		function expAdd(cardNo) {
        d = $("#dlg").dialog({
        title: '慢性病报销',
        width: 380,
        height: 380,
        href: '${path}/expInst/addPage?cardNo='+cardNo,
        maximizable:true,
	    modal:true,
	    buttons:[{
			text:'计算',
			handler:function(){
				var form = $("#mainform");  
				var allCost = $("input[ name='allCost' ] ").val();
				if(allCost==undefined || allCost==0 || allCost==''){
					$.messager.alert('提示','请先输入总花费！'); 
					return;
				}
				$.ajax({
					async:false,
					type:'POST',
					data: form.serialize(),

					url:'${path}/expInst/precreate',
					success: function(data){
						jsondata=$.parseJSON(data);
						alert(jsondata.bxPay);
						var bxPay = $("input[ name='bxPay' ] ").val(jsondata.bxPay);
					}
				});
			}
		},{
			text:'确认',
			handler:function(){
				$("#mainform").submit(); 
			}
		},{
			text:'取消',
			handler:function(){
					d.panel('close');
				}
		}]
	});
}
		 function searchCardFun() {
			 alert("kkk");
			 familyInfoDg.datagrid('load', $.serializeObject($('#searchCardForm')));
		    }
		    function cleanCardFun() {
		        $('#searchCardForm input').val('');
		        familyInfoDg.datagrid('load', {});
		    }
		//时间格式化
		function dateFormatter(value) {
			var date = new Date(value);
			return dateFtt('yyyy-MM-dd hh:mm:ss', date);
		}
	</script>
</body>
</html>